#define _CRT_SECURE_NO_WARNINGS 1
#include"string.h"

class A
{
public:
	typedef char* iterator;
	typedef const char* const_iterator;
	//iterator begin()
	//{
	//	return _str;
	//}
	iterator begin() const
	{
		return _str;
	}
	A(const char* str = "")
	{
		_str = new char[10];
		strcpy(_str, str);
	}
	/* const */ char& operator[](size_t pos) const
	{
		return _str[pos];
	}
private:
	char* _str;
};
void test1()
{
	const A str("123");
	//const A str --> const A const * this
	//A str --> A const * this
	A str2("123");
	str[1] = 2;
}
void test2()
{
	const A str("123");
	A::iterator it;
	it = str.begin();
	*it = *(it)+2;
	cout << *it << endl;
}

void string_test8()
{
	string s;
	s.resize(10, 'a');
	cout << s.c_str() << endl;


	s.resize(20, 'b');
	cout << s.c_str() << endl;


	s.resize(13, 'b');
	cout << s.c_str() << endl;
	/*string s1("ssss");
	s1.resize(10);
	cout << s1.c_str() << endl;

	string s2("ssss");
	s2.resize(10, 'a');
	cout << s2.c_str() << endl;

	string s3("ssss");
	s3.resize(1);
	cout << s3.c_str() << endl;

	string s4("ssss");
	s4.resize(1, 'a');
	cout << s4.c_str() << endl;*/

}
void string_test7()
{
	string s("hello world");

	s.insert(0, 3, 'a');
	cout << s.c_str() << endl;
	s.insert(4, 3, 'a');
	cout << s.c_str() << endl;
	s.insert(5, "  xxx");
	cout << s.c_str() << endl;
	s.insert(8, "  dddddd");
	cout << s.c_str() << endl;
	s.erase(2, 2);
	cout << s.c_str() << endl;
	s.erase(2, 40);
	cout << s.c_str() << endl;

}
int main()
{
	//test2();
	//const int N = 10;
	//int a[N] = { 0 };
	string_test7();
	cout << "----------------------" << endl;
	B::string_test7();
	//string s("aaaaaaaaa");
	//cout << s.capacity() << endl;
	//s.reserve(2);
	//cout << s.c_str() << endl;
	//cout << s.capacity() << endl;

	return 0;
}